﻿using System;
using System.Collections.Generic;
using System.Data;

namespace Sample
{
	public partial class DataVisualization : System.Web.UI.Page
	{
		protected void filterButton_Click(object sender, EventArgs e)
		{
			sampleObjectDataSource.FilterExpression = filterDropDownList.SelectedValue + " like '%" + filterTextBox.Text + "%'";
			sampleGridView.DataBind();
		}
	}

	public class Person
	{
		private static List<Person> persons;
		private static DataTable table;

		static Person()
		{
			persons = new List<Person>();
			for (int i = 0; i < 400; i++)
				persons.Add(new Person("Fulano" + i, "fulano" + i + "@folks.com"));

			table = new DataTable("Person");
			table.Columns.Add("Name");
			table.Columns.Add("Email");
		}

		public Person()
		{
		}

		public Person(string name, string email)
		{
			Name = name;
			Email = email;
		}

		private string name;

		public string Name
		{
			get { return name; }
			set { name = value; }
		}

		private string email;

		public string Email
		{
			get { return email; }
			set { email = value; }
		}

		public List<Person> GetList()
		{
			return persons;
		}

		public DataTable GetDataTable()
		{
			table.Clear();
			foreach (Person p in GetList())
			{
				DataRow row = table.NewRow();
				row["Name"] = p.Name;
				row["Email"] = p.Email;
				table.Rows.Add(row);
			}
			return table;
		}
	}
}
